import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login.vue'
import Home from '../components/Home.vue'
import Welcome from '../components/Welcome.vue'
import temp from '../components/temp.vue'
import Qrcode from '../components/Qrcode'
import Jurisdiction from '../components/Jurisdiction.vue'
import Scrap from '../components/Storehouse1/Scrap.vue'
import Stock from '../components/Storehouse1/Stock.vue'
import Inventory from '../components/Storehouse1/Inventory.vue'
import Delivery from '../components/Storehouse1/Delivery.vue'
import Acceptance from '../components/Storehouse1/Acceptance.vue'
import Edit from '../components/Storehouse1/Edit.vue'
import Edit1 from '../components/Storehouse1/Edit1.vue'
import Edit2 from '../components/Storehouse1/Edit2.vue'
import Edit3 from '../components/Storehouse1/Edit3.vue'
import Statistics from '../components/Storehouse1/Statistics'
import Detail1 from '../components/Storehouse1/detail1.vue'
import Detail2 from '../components/Storehouse1/detail2.vue'
import Detail3 from '../components/Storehouse1/detail3.vue'
import Detail4 from '../components/Storehouse1/detail4.vue'
import Scrap1 from '../components/Storehouse2/Scrap1.vue'
import Stock1 from '../components/Storehouse2/Stock1.vue'
import Inventory1 from '../components/Storehouse2/Inventory1.vue'
import Delivery1 from '../components/Storehouse2/Delivery1.vue'
import Acceptance1 from '../components/Storehouse2/Acceptance1.vue'
import StandbyEdit from '../components/Storehouse2/Edit.vue'
import StandbyEdit1 from '../components/Storehouse2/Edit1.vue'
import StandbyEdit2 from '../components/Storehouse2/Edit2.vue'
import StandbyEdit3 from '../components/Storehouse2/Edit3.vue'
import Statistics1 from '../components/Storehouse2/Statistics1'
import Operation from '../components/Storehouse1/Operation'
import Operation1 from '../components/Storehouse1/Operation1'
import Operation2 from '../components/Storehouse1/Operation2'
import Operation3 from '../components/Storehouse1/Operation3'
//import Cookies from 'js-cookie'

Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/login' },
  { path: '/login', component: Login },
  { path: '/qrcode', component: Qrcode },
  {
    path: '/home',
    component: Home,
    redirect: 'welcome',
    children: [
      {
        path: 'welcome',
        component: temp,
        children: [
          { path: '', component: Welcome, name: '首页', },
        ]
      },
      {
        path: 'storehouse1',
        component: temp,
        children: [
          { path: '', component: Stock, name: '库存管理', meta: { title: "库存管理" } },
          { path: 'stock', component: Stock, name: '库存管理', meta: { title: "库存管理" } },
          { path: 'acceptance', component: Acceptance, name: '入库管理', meta: { title: "入库管理" } },
          { path: 'delivery', component: Delivery, name: '出库管理', meta: { title: "出库管理" } },
          { path: 'scrap', component: Scrap, name: '报废管理', meta: { title: "报废管理" } },
          { path: 'inventory', component: Inventory, name: '盘点管理', meta: { title: "盘点管理" } },
          { path: 'detail1', component: Detail1, name: '入库单打印', meta: { title: "入库单打印" } },
          { path: 'detail2', component: Detail2, name: '出库单打印', meta: { title: "出库单打印" } },
          { path: 'detail3', component: Detail3, name: '报废单打印', meta: { title: "报废单打印" } },
          { path: 'detail4', component: Detail4, name: '盘点单打印', meta: { title: "盘点单打印" } },
          { path: 'edit', component: Edit, name: '入库单填报', meta: { title: "入库单填报" } },
          { path: 'edit1', component: Edit1, name: '出库单填报', meta: { title: "出库单填报" } },
          { path: 'edit2', component: Edit2, name: '报废单填报', meta: { title: "报废单填报" } },
          { path: 'edit3', component: Edit3, name: '盘点单填报', meta: { title: "盘点单填报" } },
          { path: 'operation', component: Operation, name: '退还入库', meta: { title: "退还入库操作" } },
          { path: 'operation1', component: Operation1, name: '货品操作', meta: { title: "出库货品操作" } },
          { path: 'operation2', component: Operation2, name: '货品操作', meta: { title: "报废货品操作" } },
          { path: 'operation3', component: Operation3, name: '货品操作', meta: { title: "盘点货品操作" } },
          { path: 'statistics', component: Statistics, name: '库存统计', meta: { title: "库存统计" } }]
      },
      {
        path: 'storehouse2',
        component: temp,
        children: [
          { path: '', component: Stock1, name: '库存管理', meta: { title: "库存管理" } },
          { path: 'stock', component: Stock1, name: '库存管理', meta: { title: "库存管理" } },
          { path: 'acceptance', component: Acceptance1, name: '入库管理', meta: { title: "入库管理" } },
          { path: 'delivery', component: Delivery1, name: '出库管理', meta: { title: "出库管理" } },
          { path: 'scrap', component: Scrap1, name: '报废管理', meta: { title: "报废管理" } },
          { path: 'inventory', component: Inventory1, name: '盘点管理', meta: { title: "盘点管理" } },
          { path: 'detail1', component: Detail1, name: '入库单打印', meta: { title: "入库单打印" } },
          { path: 'detail2', component: Detail2, name: '出库单打印', meta: { title: "出库单打印" } },
          { path: 'detail3', component: Detail3, name: '报废单打印', meta: { title: "报废单打印" } },
          { path: 'detail4', component: Detail4, name: '盘点单打印', meta: { title: "盘点单打印" } },
          { path: 'edit', component: StandbyEdit, name: '入库单填报', meta: { title: "入库单填报" } },
          { path: 'edit1', component: StandbyEdit1, name: '出库单填报', meta: { title: "出库单填报" } },
          { path: 'edit2', component: StandbyEdit2, name: '报废单填报', meta: { title: "报废单填报" } },
          { path: 'edit3', component: StandbyEdit3, name: '盘点单填报', meta: { title: "盘点单填报" } },
          { path: 'statistics', component: Statistics1, name: '库存统计', meta: { title: "库存统计" } }]
      },
      {
        path: 'jurisdiction',
        component: temp,
        children: [
          { path: '', component: Jurisdiction, name: '权限管理', meta: { title: "权限管理" } },
        ]
      },
      {
        path: '*',
        redirect: 'welcome',
      }
    ]
  },
]

const router = new VueRouter({
  routes
})
// router.beforeEach((to, from, next) => {
// console.log(to);
// if (to.meta && to.meta.noAuth) {
// console.log('.....');
// next();
// } else {
// const loggedIn = Cookies.get('loggedIn')
// console.log(loggedIn == 'true')
// if (loggedIn !== 'true' && to.path !== '/login') {
// next('/login')
// } else {
// next()
// }
// }
// })

export default router
